package com.ricky.base.repository;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.NoRepositoryBean;
import org.springframework.transaction.annotation.Transactional;

import java.io.Serializable;

/**
 * @Author Ricky
 * @Date 2024/6/20 14:08
 * @Description: 公共jpaRepository
 */
@NoRepositoryBean
public interface BaseRepository<E, ID extends Serializable> extends JpaRepository<E, ID>, JpaSpecificationExecutor<E> {


    @Modifying//增删改操作必须要有这个注解
    @Transactional // 事务的注解
    @Query(value = "UPDATE INSP_INSPECTOR SET CONFIDENTIALITY_AGREEMENT ='1' WHERE ID = ? ",nativeQuery = true) // nativeQuery 表示自然的sql数据库语句，
    void updateInspAssesement(String id);

    Page<E> findAll(Specification<E> spec, Pageable pageable);
}

